<?php
/**
 * 功能描述：	系统主页
 * @datetime	2022-07-07
 * @version   	v2.3
 * @author   	ZHL
 * @copyrigh  	2022 ZHL 版权所有
 */

class Admin_IndexServe{

    /**
     * Notes: 获取时间段登录日志
     * User: ZhuHaili
     */
	public function getUserLoginLogList($startDate, $endDate){
	    $result = array('code'=>'40000','msg'=>'fail');
        if(!$startDate || !$endDate){
            return $result;
        }
        $startDate = date('Y-m-d 00:00:00',strtotime($startDate));
        $endDate = date('Y-m-d 23:59:59',strtotime($endDate));
        if($startDate <= '1970-01-01 00:00:00'){
            $result['code'] = '40001';
            return $result;
        }
        if($endDate <= '1970-01-01 23:59:59'){
            $result['code'] = '40002';
            return $result;
        }
        $main = new Admin_IndexModel();
        $list = $main->getUserLoginLogList($startDate, $endDate);
        if(empty($list)){
            $result['code'] = '30000';
            return $result;
        }
        $result['code'] = '10000';
        $result['msg'] = 'success';
        $result['data']['list'] = $list;
        $result['data']['sumno'] = count($list);
        return $result;
    }

    /**
     * Notes: 获取时间段操作日志
     * User: ZhuHaili
     */
    public function getUserOperateLogList($startDate, $endDate){
        $result = array('code'=>'40000','msg'=>'fail');
        if(!$startDate || !$endDate){
            return $result;
        }
        $startDate = date('Y-m-d 00:00:00',strtotime($startDate));
        $endDate = date('Y-m-d 23:59:59',strtotime($endDate));
        if($startDate <= '1970-01-01 00:00:00'){
            $result['code'] = '40001';
            return $result;
        }
        if($endDate <= '1970-01-01 23:59:59'){
            $result['code'] = '40002';
            return $result;
        }
        $main = new Admin_IndexModel();
        $list = $main->getUserOperateLogList($startDate, $endDate);
        if(empty($list)){
            $result['code'] = '30000';
            return $result;
        }
        $result['code'] = '10000';
        $result['msg'] = 'success';
        $result['data']['list'] = $list;
        $result['data']['sumno'] = count($list);
        return $result;
    }

}